package com.dks.repository.impl;

import java.util.List;
import java.util.Map;

import com.dks.mapper.AdvertisingMapper;
import com.dks.models.Advertising;
import com.dks.repository.IAdvertisingRepository;
import com.dks.result.Result;
import com.dks.result.ResultInfo;
import com.dks.result.ResultModel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class AdvertisingRepository implements IAdvertisingRepository {

    private AdvertisingMapper advertisingMapper;

    @Autowired
    public AdvertisingRepository(final AdvertisingMapper advertisingMapperIn) {
        this.advertisingMapper = advertisingMapperIn;
    }

    @Override
    public Integer insert(Advertising advertising) {
        return advertisingMapper.insert(advertising);
    }

    @Override
    public Integer update(Advertising advertising) {
        return advertisingMapper.update(advertising);
    }

    @Override
    public Integer delete(Integer id) {
        return advertisingMapper.delete(id);
    }

    @Override
    public Advertising select(Integer id) {
        return advertisingMapper.select(id);
    }

    @Override
    public Integer cntByMap(Map<String, Object> map) {
        return advertisingMapper.cntByMap(map);
    }

    @Override
    public List<Integer> getByMap(Map<String, Object> map) {
        return advertisingMapper.getByMap(map);
    }

    @Override
    public List<Advertising> getByMapList(Map<String, Object> map) {
        return advertisingMapper.getByMapList(map);
    }

    /**
     * @Author: Ah Nan
     * @Description: 获取首页轮播图
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param:
     * @return:
     * @throw: 请描述异常信息
     */
    @Override
    public ResultModel<Object> getAdvertisingInfo(Map<String, Object> map) {

        List<Advertising> advertisingList = advertisingMapper.getByMapList(map);
        return Result.makeResult(ResultInfo.SUCCESS, advertisingList);

    }

}
